#pragma once

#include "../Service/Interface.hpp"


const static char titles[] = "  高  校  自  动  排  课  系  统  ";

class EntryInterface :public Interface{
public:
  EntryInterface(int entry_row = LINES * 4 / 5, int entry_col = COLS / 3, 
      int entry_start_r = LINES / 10, int entry_start_c = COLS / 3)
  :win(entry_row, entry_col, entry_start_r, entry_start_c) {}

  void DrawInterface() override {
    init_pair(0, COLOR_BLACK, COLOR_WHITE);
    win.DrawBox();
    wrefresh(win.getPoint());
    
    getmaxyx(win.getPoint(), title_row, title_col);
    title_row /= 6;
    title_col /= 4;

    wattron(win.getPoint(), A_STANDOUT);  //打开字符属性
    //mvwprintw(win.getPoint(), title_row, title_col, "%s", titles);
    mvwaddstr(win.getPoint(), title_row, title_col - 5, titles);
    wattroff(win.getPoint(), A_STANDOUT); //关闭字符属性

    if(!has_colors() || start_color() == ERR){
      //TODO
      //判断终端是否支持颜色显示
      return;
    }

    getmaxyx(win.getPoint(), title_row, title_col);
    title_row /= 6;
    title_col /= 2;

    init_pair(1, COLOR_BLUE, COLOR_WHITE);//设置颜色对
    wattron(win.getPoint(), COLOR_PAIR(1));
    mvwaddstr(win.getPoint(), title_row + 5, title_col - 3, "登  录");
    wattroff(win.getPoint(), COLOR_PAIR(1));

    title_row += 9;
    title_col /= 2;
    title_col -= 1;
    mvwaddstr(win.getPoint(), title_row, title_col, "账 号:");
    mvwaddstr(win.getPoint(), title_row + 3, title_col, "密 码:");

    wrefresh(win.getPoint());
  }

private:
  Window win;
  int title_row;
  int title_col;
};
